home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / VPARM.CPP < prev    next >
C/C++ Source or Header  |  1993-08-26  |  5KB  |  173 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    vparm.cpp
  5. //   Title:    VOX and ME/2 Interface
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //    This module contains the program entry point for
  24. //
  25. //    The code in this module may be written in C++ or C.
  26. //
  27. //    This module is portable to:
  28. //        DOS 3.X+
  29. //        MS Windows 3.X+
  30. //        MS Windows NT
  31. //        OS/2 2.X+
  32. //        OS/2 2.0 PM
  33. //
  34. //    The following compilers are supported:
  35. //        MSC 6.0A
  36. //        MSC/C++ 7.0
  37. //        Borland C++ 3.1 for DOS
  38. //        Borland C++ 1.0 for OS/2 2.X
  39. //
  40. //----------------------------------------------------------------------------
  41. #include <vox.hpp>
  42.  
  43.  
  44. //----------------------------------------------------------------------------
  45. //    Stack size
  46. //----------------------------------------------------------------------------
  47. #if COMPILER_BORLAND && (OS_DOS || OS_WINDOWS)
  48. unsigned _stklen = 0x4000;
  49. #endif
  50.  
  51.  
  52. //----------------------------------------------------------------------------
  53. //    Globals
  54. //----------------------------------------------------------------------------
  55.  
  56. //
  57. // A useless string which is simply embedded in the executable.
  58. //
  59. PSZ __pszCredits__ = "Written by John M Weeder, 1993";
  60.  
  61.  
  62. //
  63. //    This should contain a program description which will be displayed as
  64. //    part of the program's help text.
  65. //
  66. static PCSZ pcszDescription =
  67.     "This program is used to modify a VOX program's configuration";
  68.  
  69. //
  70. //    Program command line options
  71. //
  72. #define MAX_PARAMETERS        (50)
  73. #define MAX_TEXT_PARM        (40)
  74. static LONG alVal[MAX_PARAMETERS];
  75. static CHAR aszText[MAX_PARAMETERS][MAX_TEXT_PARM+1];
  76. static CHAR szConfig[MAX_PATH+1];
  77. static BS_CMDOPT acmdopt[MAX_PARAMETERS+2] =
  78.     {
  79.     { "config", (PVOID)szConfig,     CMDOPT_FILESPECR(80),    "Configuration file." },
  80.     // The remainder are zeroed at startup!!!
  81.     };
  82.  
  83.  
  84. //----------------------------------------------------------------------------
  85. //   Description:    main() - Program entry point
  86. //    Parameters:    Standard C parameters
  87. //       Returns:    DOS return code.
  88. //----------------------------------------------------------------------------
  89. int main(int argc, char **argv)
  90. {
  91. static BS_CFG cfg = CFG_DFT;
  92.  
  93.     //
  94.     //    Initialize base library
  95.     //
  96.     BaseLibraryInitialize(argc, argv, &cfg);
  97.     BaseTitle("$Revision:  93.1  $", __DATE__, __TIME__, "VOX Configuration Utility");
  98.  
  99.     //
  100.     //    Build the command line parameter list dynamically.
  101.     //    Do not place default values!!!
  102.     //
  103.     Assert(VX_PARM_MAX <= MAX_PARAMETERS);
  104.     for (SIZET i = 0; i < VX_PARM_MAX; ++i)
  105.         {
  106.         PCSZ pcszName = VX_VOX::GetParmName((VX_PARM)i);
  107.         PCSZ pcszPeriod = strchr(pcszName, '.');
  108.         if (pcszPeriod)
  109.             pcszName = pcszPeriod + 1;
  110.         Assert(pcszName && pcszName[0]);
  111.  
  112.         acmdopt[i+1].psz = (PSZ)pcszName;
  113.         if (VX_VOX::GetParmType((VX_PARM)i) == VX_PARM_INTEGER)
  114.             {
  115.             acmdopt[i+1].pv = (PVOID)&alVal[i];
  116.             acmdopt[i+1].fs = CMDOPT_NUMERIC|CMDOPT_NO_DFT;
  117.             }
  118.         else
  119.             {
  120.             acmdopt[i+1].pv = (PVOID)aszText[i];
  121.               acmdopt[i+1].fs = CMDOPT_TEXT(MAX_TEXT_PARM)|CMDOPT_NO_DFT;
  122.             }
  123.         acmdopt[i+1].pszDesc = (PSZ)VX_VOX::GetParmDesc((VX_PARM)i);
  124.         }
  125.  
  126.     //
  127.     //    Read command line and then open the config file.
  128.     //
  129.     if (!BaseTitleHelp(acmdopt, pcszDescription))
  130.         return 99;
  131.  
  132.     if (!CfgOpen(szConfig))
  133.         return 99;
  134.  
  135.     //
  136.     //    Update any values which were changed.
  137.     //
  138.     VX_VOX::LoadParms();
  139.     for (i = 0; i < VX_PARM_MAX; ++i)
  140.         if (BTEST(acmdopt[i+1].fs, CMDOPT_USED))
  141.             {
  142.             if (VX_VOX::GetParmType((VX_PARM)i) == VX_PARM_INTEGER)
  143.                 {
  144.                 VX_VOX::SetParm((VX_PARM)i, alVal[i]);
  145.                 }
  146.             else
  147.                 {
  148.                 VX_VOX::SetParm((VX_PARM)i, aszText[i]);
  149.                 }
  150.             }
  151.     //
  152.     //    Finally, display the current values of the parameters!
  153.     //
  154.     Output("VOX Parameters:\n");
  155.     for (i = 0; i < VX_PARM_MAX; ++i)
  156.         {
  157.         Output("   %s=", VX_VOX::GetParmName((VX_PARM)i));
  158.         if (VX_VOX::GetParmType((VX_PARM)i) == VX_PARM_INTEGER)
  159.             {
  160.             Output("%ld\n", VX_VOX::GetParmInt((VX_PARM)i));
  161.             }
  162.         else
  163.             {
  164.             Output("%s\n", VX_VOX::GetParmStr((VX_PARM)i));
  165.             }
  166.         }
  167.     Output("\nSuccess.\n\n");
  168.     return 0;
  169. }
  170. //----------------------------------------------------------------------------
  171. //------------------------------- End of File --------------------------------
  172. //----------------------------------------------------------------------------
  173.